﻿<UserControl
    x:Class="WinRTXamlToolkit.Sample.Views.HighlightBehaviorTestView"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:WinRTXamlToolkit.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:charting="using:WinRTXamlToolkit.Controls.DataVisualization.Charting"
    xmlns:Series="using:WinRTXamlToolkit.Controls.DataVisualization.Charting"
    xmlns:Interactivity="using:WinRTXamlToolkit.Interactivity"
    xmlns:Behaviors="using:WinRTXamlToolkit.Controls.Behaviors">

    <Grid
        VerticalAlignment="Center"
        HorizontalAlignment="Center">
        <Grid.ColumnDefinitions>
            <ColumnDefinition
                Width="*"
                MinWidth="200"
                MaxWidth="400" />
            <ColumnDefinition
                Width="*"
                MinWidth="200"
                MaxWidth="400" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition
                Height="Auto" />
            <RowDefinition
                Height="Auto" />
            <RowDefinition
                Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.Resources>
            <Style
                x:Key="LabelStyle"
                TargetType="TextBlock">
                <Setter
                    Property="FontSize"
                    Value="18" />
                <Setter
                    Property="HorizontalAlignment"
                    Value="Right" />
            </Style>
            <Style
                x:Key="TextStyle"
                TargetType="TextBlock">
                <Setter
                    Property="FontSize"
                    Value="24" />
                <Setter
                    Property="TextWrapping"
                    Value="Wrap" />
            </Style>
        </Grid.Resources>
        <TextBlock
            Grid.Row="0"
            Text="TextBlock.Text Value"
            Style="{StaticResource LabelStyle}" />
        <TextBox
            x:Name="textBox"
            Text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna."
            Grid.Row="0"
            Grid.Column="1"
            TextWrapping="Wrap"
            Margin="0,0,0,10" />
        <TextBlock
            Grid.Row="1"
            Text="Search String"
            Style="{StaticResource LabelStyle}" />
        <TextBox
            x:Name="searchBox"
            Text="{Binding SearchString, Mode=TwoWay}"
            Grid.Row="1"
            Grid.Column="1"
            Margin="0,0,0,10"
            TextChanged="OnSearchStringChanged" />
        <TextBlock
            Grid.Row="2"
            Text="Basic HighlightBehavior"
            Style="{StaticResource LabelStyle}" />
        <TextBlock
            x:Name="highlightedTextBlock"
            Grid.Row="2"
            Grid.Column="1"
            Style="{StaticResource TextStyle}"
            Text="{Binding Text, ElementName=textBox}">
                <Interactivity:Interaction.Behaviors>
                    <Behaviors:HighlightBehavior
                    x:Name="highlightBehavior"
                    SearchString="{Binding SearchString, Mode=TwoWay}" />
                    <!-- Note - ElementName binding as below doesn't work. Seems like namescope issues block it. -->
                    <!--SearchString="{Binding Text, ElementName=searchBox}"-->
                </Interactivity:Interaction.Behaviors>
        </TextBlock>
    </Grid>
</UserControl>